package com.cw.subject.infra.basic.service.impl;

import com.cw.subject.infra.basic.entity.SubjectRadioPO;
import com.cw.subject.infra.basic.mapper.SubjectRadioPODao;
import com.cw.subject.infra.basic.service.SubjectRadioPOService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 单选题信息表(SubjectRadioPO)表服务实现类
 *
 * @author makejava
 * @since 2024-04-11 15:31:55
 */
@Service("subjectRadioService")
public class SubjectRadioPOServiceImpl implements SubjectRadioPOService {
    @Resource
    private SubjectRadioPODao subjectRadioPODao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public SubjectRadioPO queryById(Integer id) {
        return this.subjectRadioPODao.queryById(id);
    }

    /**
     * 新增数据
     *
     * @param subjectRadioPO 实例对象
     * @return 实例对象
     */
    @Override
    public SubjectRadioPO insert(SubjectRadioPO subjectRadioPO) {
        this.subjectRadioPODao.insert(subjectRadioPO);
        return subjectRadioPO;
    }

    /**
     * 修改数据
     *
     * @param subjectRadioPO 实例对象
     * @return 实例对象
     */
    @Override
    public SubjectRadioPO update(SubjectRadioPO subjectRadioPO) {
        this.subjectRadioPODao.update(subjectRadioPO);
        return this.queryById(subjectRadioPO.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.subjectRadioPODao.deleteById(id) > 0;
    }

    /**
     * @author: 江传文
     * @date: 2024/4/14 14:32
     * 批量插入
     */
    @Override
    public void batchInsert(List<SubjectRadioPO> subjectRadioList) {
        this.subjectRadioPODao.insertBatch(subjectRadioList);
    }

    /**
     * @author: 江传文
     * @date: 2024/4/14 14:32
     * 条件查询
     */
    @Override
    public List<SubjectRadioPO> queryByCondition(SubjectRadioPO subjectRadioPO) {
        return subjectRadioPODao.queryAllByLimit(subjectRadioPO);
    }
}
